#ifndef _CHANNEL_H_
#define _CHANNEL_H_

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <vector>

struct Block
{
    int id;
    int height;
    int position;
};

class Channel : public cv::Mat
{
  private:
    int color; //0 rouge, 1 vert, 2 blue
  protected:
    template <typename T>
	void setHistData(T data[], int N);
  public:
    Channel();
    Channel(cv::Mat image, int c);
    Channel(Channel& channel);
    Channel& operator=(const Channel& channel);
    void drawHistogram(cv::Mat &hist_background, int color);
    void detectBlock(std::vector<Block> &blocks, bool space);
    void detectBlock(std::vector<Block> &blocks, int seuil);
    static bool compare(double a, double b, double e);
    static bool compare(cv::Mat image1, cv::Mat image2,
			std::vector<Block> v1, std::vector<Block> v2, double e);
    static double score(cv::Mat img1, cv::Mat img2);
    static double different(cv::Mat img1, cv::Mat img2);
    static double diffBlock(cv::Mat img1, cv::Mat img2);
    static void detectBlock(cv::Mat image, int start, int end, cv::Mat &block);
    void detectBlock(std::vector<cv::Mat> &blocks, int seuil);
    cv::Mat preprocess(cv::Mat image, int option);
    static bool nearBoard(int i, int j, cv::Mat image);

    
    friend cv::Scalar getScalar(Channel);
    int getColor();
    virtual ~Channel();
};

#endif /* _CHANNEL_H_ */
